package com.tobie.info.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tobie.info.entity.FlightEntity;
import com.tobie.info.mapper.FlightMapper;

import com.tobie.info.service.IFlightService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author lc
 * @Date 2023/11/17 10:06
 * @注释 航班信息实现类
 */

@Slf4j
@Service
public class FlightServiceImpl extends ServiceImpl<FlightMapper, FlightEntity> implements IFlightService {

    @Override
    public List<FlightEntity> getFlightByLeaveCityAndArriverCity(String leaveCity, String arriverCity) {
        QueryWrapper<FlightEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("t_flight_leave_city", leaveCity)
                    .eq("t_flight_arriver_city", arriverCity);
        //"t_flight_leave_city" 是数据库中的字段名
        return this.baseMapper.selectList(queryWrapper);
    }

    @Override
    public List<FlightEntity> getAllFlight() {
        List<FlightEntity> flightEntities = this.baseMapper.selectList(null);
        log.info(flightEntities.toString());
        return flightEntities;
    }
}
